package cn.trigram.validation.annotation;


import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.TYPE_USE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import cn.trigram.validation.annotation.validator.EnumValueForCharValidator;
import cn.trigram.validation.annotation.validator.EnumValueForIntegerValidator;
import cn.trigram.validation.annotation.validator.EnumValueForLongValidator;
import cn.trigram.validation.annotation.validator.EnumValueForShortValidator;
import cn.trigram.validation.annotation.validator.EnumValueForStringValidator;
import java.lang.annotation.Documented;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.validation.Constraint;
import javax.validation.Payload;

/**
 * 枚举值的校验，不是对枚举的校验。校验字段值是否在给定枚举的所有的值内
 *
 * @version 1.0.0
 * @date 2023/05/09 14:09:14
 * @since 1.0.0
 */
@Target({FIELD, METHOD, PARAMETER, ANNOTATION_TYPE, TYPE_USE})
@Retention(RUNTIME)
@Constraint(validatedBy = {EnumValueForStringValidator.class, EnumValueForIntegerValidator.class, EnumValueForLongValidator.class, EnumValueForShortValidator.class, EnumValueForCharValidator.class})
@Documented
@Repeatable(EnumValueCheck.List.class)
public @interface EnumValueCheck {

    String message() default "{gf.util.validation.EnumValueCheck.message}";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

    Class<? extends Enum<?>> value();

    @Target({FIELD, METHOD, PARAMETER, ANNOTATION_TYPE})
    @Retention(RUNTIME)
    @Documented
    @interface List {

        EnumValueCheck[] value();
    }
}
